package com.mzy.olddate.test;

import java.util.ArrayList;

/**
 * @author Ives
 * * @date 2021/9/10
 */
public class testColumnColCode {
  public static void main(String[] args) {
//    String s="010700910990990010";
    String s="010700910030010030";
    System.out.println(s);
    // 截取前9位功能位
    String substring = s.substring(0, 9);
//    System.out.println(substring);
    // 截取9位往后的标记位
//    String substring1 = s.substring(9);
    String demo = demo(s);
    System.out.println(demo);
    for (int i = 0; i < 890; i++) {
      demo = demo(demo);
      System.out.println(demo);
    }

  }
  // 每个栏目节点下极限值支持892个栏目
  public static String demo(String s){
    String strAfter = s.substring(9);
    ArrayList<String> list = new ArrayList<>();
    for (int i = 0; i < strAfter.length(); i=i+3) {
      list.add(strAfter.substring(i,i+2));
    }
//    System.out.println(list.size()*2);
    StringBuilder stringBuilder = new StringBuilder();
    for (String item:
            list) {
      stringBuilder.append(item);
    }
//    String aaa = stringBuilder.toString();
//    System.out.println("aaa"+aaa);

    Long aLong = Long.parseLong(stringBuilder.toString())+1;
    String s1 = String.valueOf(aLong);
    // 如果长度为1,则代表为前9位需要补零
    if (s1.length()==1){

      s1=String.format("%02d", aLong);
    }
//    System.out.println(s1);

    if (s1.length() % 2 !=0){
      StringBuilder stringBuilder1 = new StringBuilder();
      stringBuilder1.append(s.substring(0,9));
      for (int i = 0; i < list.size(); i++) {
        stringBuilder1.append("990");
      }
//      System.out.println(stringBuilder1.append("010").toString());
      return stringBuilder1.append("010").toString();
    }else {

      StringBuilder stringBuilder1 = new StringBuilder();
      stringBuilder1.append(s, 0, 9);
      ArrayList<String> list1 = new ArrayList<>();
      for (int i = 0; i < s1.length(); i=i+2) {
        list1.add(s1.substring(i,i+2));
      }
      for (String item:
              list1) {
        stringBuilder1.append(item+"0");
      }
//      System.out.println(stringBuilder1.toString());
      return stringBuilder1.toString();
    }
  }
}
